package com.steptime.security;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
import org.springframework.security.core.userdetails.MapReactiveUserDetailsService;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

@EnableWebFluxSecurity
@Configuration
public class SecurityConfiguration {

	Log log = LogFactory.getLog(this.getClass());

	// @formatter:off
	@Bean
	public MapReactiveUserDetailsService userDetailsService() {
		log.info("用户登录验证");
		UserDetails user = User.withDefaultPasswordEncoder()
				.username("admin")
				.password("123456")
				.roles("USER")
				.build();
		return new MapReactiveUserDetailsService(user);
	}
	// @formatter:on

}